package website.lucaswork.survey.core.converters;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import website.lucaswork.survey.core.utils.DefaultValues;

@Component
public class BooleanToStringConverter implements Converter<Boolean, String> {

    @Autowired
    DefaultValues defaultValues;

    @Override
    public String convert(Boolean source) {
        if (source.equals(Boolean.TRUE)) {
            return defaultValues.getDefaultTrueText();
        } else {
            return defaultValues.getDefaultFalseText();
        }
    }
}
